package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzSypic;
import com.ruoyi.system.service.IDzSypicService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商业相册Controller
 * 
 * @author ruoyi
 * @date 2023-09-17
 */
@RestController
@RequestMapping("/system/sypic")
public class DzSypicController extends BaseController
{
    @Autowired
    private IDzSypicService dzSypicService;

    /**
     * 查询商业相册列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzSypic dzSypic)
    {
        startPage();
        List<DzSypic> list = dzSypicService.selectDzSypicList(dzSypic);
        return getDataTable(list);
    }

    /**
     * 导出商业相册列表
     */
    @Log(title = "商业相册", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzSypic dzSypic)
    {
        List<DzSypic> list = dzSypicService.selectDzSypicList(dzSypic);
        ExcelUtil<DzSypic> util = new ExcelUtil<DzSypic>(DzSypic.class);
        util.exportExcel(response, list, "商业相册数据");
    }

    /**
     * 获取商业相册详细信息
     */
    @GetMapping(value = "/{sxId}")
    public AjaxResult getInfo(@PathVariable("sxId") Long sxId)
    {
        return AjaxResult.success(dzSypicService.selectDzSypicBySxId(sxId));
    }

    /**
     * 新增商业相册
     */
    @Log(title = "商业相册", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzSypic dzSypic)
    {
        return toAjax(dzSypicService.insertDzSypic(dzSypic));
    }

    /**
     * 修改商业相册
     */
    @Log(title = "商业相册", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzSypic dzSypic)
    {
        return toAjax(dzSypicService.updateDzSypic(dzSypic));
    }

    /**
     * 删除商业相册
     */
    @Log(title = "商业相册", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sxIds}")
    public AjaxResult remove(@PathVariable Long[] sxIds)
    {
        return toAjax(dzSypicService.deleteDzSypicBySxIds(sxIds));
    }
}
